package com.hpf.community.utils;

import com.hpf.community.constants.Constants;

import java.util.ArrayList;

/**
 * @Description:
 * @Author: hpf
 * @Date: 2020/1/19 14:20
 */
public class PaginationResult extends StandardResult{
    private long total;  // 总条数

    private long pages;	// 总页数

    /**
     * @param state
     * @param msg
     * @param data
     * @param code
     * @param total
     * @param pages
     */
    public PaginationResult(boolean state, String msg, Object data, int code, long total, long pages) {
        super(state, msg, data, code, null);
        this.total = total;
        this.pages = pages;
    }

    public PaginationResult() {

    }

    public static StandardResult ok(String msg, Object data, long total, long pages) {
        if(data == null) {
            data = new ArrayList<Object>();
        }

        if(msg == null) {
            msg = "";
        }
        return new PaginationResult(true, msg, data, Constants.RESPONSE_CODE_SUCCESS, total, pages);
    }

    public static StandardResult ok(Object data, int total, int pages) {

        return PaginationResult.ok(null, data, total, pages);
    }


    public static StandardResult ok() {
        return PaginationResult.ok(null, 0, 0);
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public long getPages() {
        return pages;
    }

    public void setPages(int pages) {
        this.pages = pages;
    }
}
